﻿@model AddSpotCommentModel
@using Nop.Core;
@using Nop.Core.Infrastructure;
@using Nop.Web.Models.WindAlert;

@{
    Html.AppendScriptParts("~/Windalert/Scripts/jquery.autosize.js");
    Html.AppendScriptParts("~/Windalert/Scripts/jquery.limit-1.2.source.js");
}

<script type="text/javascript">

    $(function () {

        $('textarea.comment-textarea').autosize({ append: "\n" });
        $('textarea.comment-textarea').limit(100, '#charsLeft');

        @*$('#frm').validate({
            rules: {
                SpotId: "required",
                CommentText: "required",
            },
            messages: {
                SpotId: '<br><span style=\'color:Red\'>@T("WindAlert.Spot.CommentSpotMessage")</span>',
                CommentText: '<br><span style=\'color:Red\'>@T("WindAlert.Spot.CommentTextRequired")</span>',
            }
        });*@
    });

</script>

@using (Html.BeginForm("Spot", "WSpot", FormMethod.Post, new { enctype = "multipart/form-data", name = "frm", id = "frm" }))
{
    @Html.ValidationSummary(true)
    
    <div class="comment-form">
        <div class="comment-spot-list" style="display:@((Model.SpotId != 0)?"none": "normal");">
                @Html.DropDownList("SpotId", Model.AvailableSpots)
                <div>@Html.ValidationMessageFor(model => model.SpotId)</div>
            <div class="comments-charsLeft">
                @T("WindAlert.Spot.Comments.CharsLeft"): <span id="charsLeft"></span>
            </div>
            </div>
        <div class="inputs">
            <div class="comment-input">
                @Html.TextAreaFor(model => model.CommentText, new { Name = "CommentText", id = "CommentText", @class = "comment-textarea", placeholder = T("WindAlert.Spot.Comments.AddYourComment").Text })
                <div>@Html.ValidationMessageFor(model => model.CommentText)</div>               
            </div>
            <div class="comment-commands">
                <input name="add-comment" class="comment-common-btn" type="submit" value="@T("WindAlert.Spot.Comments.SubmitButton")" />
            </div>
            <div style="clear:both;"></div>
            <div class="comment-upload">
                <input type="file" id="uploadedFile" name="uploadedFile" />
                (@String.Format(T("Windalert.Spot.Comments.MaximumUploadedFileSize").Text, Model.PictureMaximumSizeBytes / 1048576))
            </div>
            
        </div>
    </div>
}

